<?php


namespace app\api\model;


use app\admin\event\SystemLog;

trait CanGetFieldModel
{

    protected static function init()
    {
        self::observe(SystemLog::class);
    }

    /**
     * @param bool $id
     * @return array
     */
    public function getFieldArray($id = true)
    {
        if (!$id) {
            $arr =  $this->getTableFields();
            unset($arr['id']);
            return $arr;
        } else {
            return $this->getTableFields();
        }
    }

    /**
     * @param bool $id
     * @return string
     */
    public function getField($id = true)
    {
        return implode(',', $this->getFieldArray($id));
    }
}
